<template>
    <div id="Sidebar">
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            :router="true"
        >
            <!-- 需要判断管理员权限 -->
            <template v-if="identity == '#/adminsSystem'">
                <el-submenu
                    v-for="item in adminsData"
                    :key="item.index"
                    :index="item.index"
                >
                    <template slot="title">
                        <i :class="item.icon"></i>
                        <span>{{ item.title }}</span>
                    </template>
                    <el-menu-item
                        v-for="sub in item.subMenu"
                        :key="sub.index"
                        :index="sub.subPath"
                        >{{ sub.subName }}</el-menu-item
                    >
                </el-submenu>
            </template>

            <!-- 销售员菜单栏 -->
            <template v-else>
                <el-submenu
                    v-for="item in salesMenData"
                    :key="item.index"
                    :index="item.index"
                >
                    <template slot="title">
                        <i :class="item.icon"></i>
                        <span>{{ item.title }}</span>
                    </template>
                    <el-menu-item
                        v-for="sub in item.subMenu"
                        :key="sub.index"
                        :index="sub.subPath"
                        >{{ sub.subName }}</el-menu-item
                    >
                </el-submenu>
            </template>
        </el-menu>
    </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState } = createNamespacedHelpers("admins");
export default {
    mounted() {
        console.log(this.identity);
    },
    data() {
        return {
            identity: location.hash.substr(0, 14),
            adminsData: [
                {
                    index: "1",
                    title: "管理员",
                    subMenu: [
                        {
                            subIndex: "1-1",
                            subName: "管理员列表",
                            subPath: "/adminsSystem/adminsList",
                        },
                        {
                            subIndex: "1-2",
                            subName: "管理员新增",
                            subPath: "/adminsSystem/adminsAdd",
                        },
                    ],
                },
                {
                    index: "2",
                    title: "销售员",
                    subMenu: [
                        {
                            subIndex: "2-1",
                            subName: "销售员列表",
                            subPath: "/adminsSystem/salesMenList",
                        },
                        {
                            subIndex: "2-2",
                            subName: "销售员新增",
                            subPath: "/adminsSystem/salesMenAdd",
                        },
                    ],
                },
                {
                    index: "3",
                    title: "客户管理",
                    subMenu: [
                        {
                            subIndex: "3-1",
                            subName: "客户列表",
                            subPath: "/adminsSystem/CustomersList",
                        },
                    ],
                },
                {
                    index: "4",
                    title: "产品分类",
                    subMenu: [
                        {
                            subIndex: "4-1",
                            subName: "产品列表",
                            subPath: "/adminsSystem/classesList",
                        },
                    ],
                },
                {
                    index: "5",
                    title: "保险产品",
                    subMenu: [
                        {
                            subIndex: "5-1",
                            subName: "保险列表",
                            subPath: "/adminsSystem/productsList",
                        },
                        {
                            subIndex: "5-2",
                            subName: "保险新增",
                            subPath: "/adminsSystem/addProducts",
                        },
                    ],
                },
                //  duchuandong
                {
                    index: "6",
                    title: "订单管理",
                    subMenu: [
                        {
                            subIndex: "6-1",
                            subName: "订单列表",
                            subPath: "/adminsSystem/mOrders/mOrdersList",
                        },
                        {
                            subIndex: "6-2",
                            subName: "退保处理",
                            subPath: "/adminsSystem/mOutOrders",
                        },
                    ],
                },
                // dcd
                {
                    index: "7",
                    title: "理赔管理",
                    subMenu: [
                        {
                            subIndex: "7-1",
                            subName: "理赔审核",
                            subPath: "/adminsSystem/claimsList",
                        },
                    ],
                },
            ],
            salesMenData: [
                {
                    index: "1",
                    title: "个人中心",
                    subMenu: [
                        {
                            subIndex: "1-1",
                            subName: "修改信息",
                            subPath: "/salesMenSystem/salesMenList",
                        },
                    ],
                },

                {
                    index: "2",
                    title: "订单管理",
                    subMenu: [
                        {
                            subIndex: "2-1",
                            subName: "订单列表",
                            subPath: "/salesMenSystem/xOrders/xOrdersList",
                        },
                    ],
                },
                {
                    index: "3",
                    title: "客户管理",
                    subMenu: [
                        {
                            subIndex: "3-1",
                            subName: "我的客户",
                            subPath: "/salesMenSystem/MyCustomers",
                        },
                        {
                            subIndex: "3-2",
                            subName: "客户新增",
                            subPath: "/salesMenSystem/AddCustomers",
                        },
                    ],
                },

                {
                    index: "4",
                    title: "理赔管理",
                    subMenu: [
                        {
                            subIndex: "4-1",
                            subName: "理赔列表",
                            subPath: "/salesMenSystem/claimsList",
                        },
                        {
                            subIndex: "4-2",
                            subName: "新增理赔",
                            subPath: "/salesMenSystem/claimsAdd",
                        },
                    ],
                },
            ],
        };
    },
    computed: {
        ...mapState(["type"]),
    },
};
</script>
